package com.lyf.shop.service.impl;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.lyf.common.core.utils.DateUtils;
import com.lyf.system.api.domain.Supermarket;
import com.lyf.shop.mapper.SupermarketMapper;
import com.lyf.shop.service.ISupermarketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 超市Service业务层处理
 * 
 * @author lyf
 * @date 2023-02-09
 */
@Service
public class SupermarketServiceImpl implements ISupermarketService
{
    @Autowired
    private SupermarketMapper supermarketMapper;

    /**
     * 查询超市
     * 
     * @param id 超市主键
     * @return 超市
     */
    @Override
    public Supermarket selectSupermarketById(Long id)
    {
        return supermarketMapper.selectSupermarketById(id);
    }

    @Override
    public List<Long> selectSupermarketListByUserId(Long userId) {

        return supermarketMapper.selectSupermarketListByUserId(userId);
    }

    @Override
    public List<Supermarket> selectSupermarketNameByUserId(Long userId) {

        return supermarketMapper.selectSupermarketNameByUserId(userId);
    }

    /**
     * 查询超市列表
     * 
     * @param supermarket 超市
     * @return 超市
     */
    @Override
    public List<Supermarket> selectSupermarketList(Supermarket supermarket)
    {
        if (supermarket.getUserId()!=0L){
            return supermarketMapper.selectSupermarketByUserId(supermarket);
        }
        return supermarketMapper.selectSupermarketList(supermarket);
    }

    /**
     * 新增超市
     * 
     * @param supermarket 超市
     * @return 结果
     */
    @Override
    public int insertSupermarket(Supermarket supermarket)
    {
        supermarket.setCreateTime(DateUtils.getNowDate());
        return supermarketMapper.insertSupermarket(supermarket);
    }

    /**
     * 修改超市
     * 
     * @param supermarket 超市
     * @return 结果
     */
    @Override
    public int updateSupermarket(Supermarket supermarket)
    {
        supermarket.setUpdateTime(DateUtils.getNowDate());
        return supermarketMapper.updateSupermarket(supermarket);
    }

    /**
     * 批量删除超市
     * 
     * @param ids 需要删除的超市主键
     * @return 结果
     */
    @Override
    public int deleteSupermarketByIds(Long[] ids)
    {
        return supermarketMapper.deleteSupermarketByIds(ids);
    }

    /**
     * 删除超市信息
     * 
     * @param id 超市主键
     * @return 结果
     */
    @Override
    public int deleteSupermarketById(Long id)
    {
        return supermarketMapper.deleteSupermarketById(id);
    }
}
